<template>
  <el-card style="height: 40%;width: 100%">
    <div>
      <div class="warp__2BP03">
        <div class="warp__1CDpL">
          <div class="warp_l__34yS8">
            ♊&nbsp;&nbsp;<span class="work__00001">个人技能</span>
          </div>
          <div class="warp_r__1-t6m">
            <img @click="addPersonalSkills(null)" class="icon_style__xOInT" alt="" src="">
            <span @click="addPersonalSkills(null)">编辑</span>
          </div>
        </div><br><br><br><br>
        <el-card shadow="hover" v-if="skillsTableData.length!==0" v-for="(item,index) in skillsTableData" :key="index">
          <div>✔️
            <span style="font-size: 20px;font-weight: 500;color: #040404;">个人技能</span>
            <span style="margin-left: 30px;font-size: 16px;color: #00B38A">{{transcodingData(item.skills)}}</span>
          </div>
        </el-card>

        <el-dialog
          style="padding: 40px 50px"
          :visible.sync="dialogVisible"
          width="550px"
          height="450px">
          <span style="margin: 0;font-size: 18px;margin-left: 24px;color: #333;">更新个人技能，让招聘方更了解你的能力</span><br><br>
          <div class="lg-modal-body" style="margin-left: 24px;">
            <div class="modal_title__1ED70">请选择个人技能</div>
            <div style="" class="modal_times_flex__1_Lej">
              <span class="modal_times_list__3kYL9" :class="{' active__3Bwk5':check_skills_exit(item.id)}" @click="skillsEdit(item.id,index)" :key="index" v-for="(item,index) in skillsOptions">{{item.name}}</span>
            </div>
          </div>
          <div class="lg-modal-footer" style="margin-left: 24px;">
            <span class="lg-modal-OK" @click="personSkillsSubmit">确认</span>
            <span class="lg-modal-cancel" @click="dialogVisible = false">取消</span>
          </div>
        </el-dialog>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  data () {
    return {
      user: {},
      resume:{},
      skillsOptions: [],
      skillsTableData: [],
      dialogVisible: false,
      form:{
        skills: [],
        resumeId: ''
      },
      classNameDataTwo: ''
    }
  },
  methods: {
    check_skills_exit(value) {
      return this.form.skills.includes(value);
    },
    transcodingData(val){//转码
      for (let i=0;i<this.skillsOptions.length;i++){
        let data = this.skillsOptions[i];
        if (data.id===val){//状态
          return data.name;
        }
      }
    },
    skillsEdit(value,index){////动态class
      var exit = false;
      if (this.form.skills.includes(value)) {
        /*根据值删除*/
        Array.prototype.contains = function (obj) {
          var i = this.length;
          while (i--) {
            if (this[i] === obj) {
              return i;
            }
          }
          return false;
        }
        this.form.skills.splice(this.form.skills.contains(value), 1)
        exit = true;
      }
      if (exit) {
        console.log("存在已被删除")
      } else if (!exit) {
        this.form.skills.push(value)
        console.log("不存在已被添加")
      }
      this.classNameDataTwo = index;
      return exit
    },
    personSkillsSubmit(){//编辑提交
      if (this.form.skills.length===0){
        this.$message({
          message: '个人技能不能为空！',
          type: 'error'
        });
        return;
      }
      this.$http({
        url: this.$http.adornUrl(`/resume/skills/save`),
        method: 'post',
        data: this.$http.adornData({
          'skills': this.form.skills,
          'resumeId': this.form.resumeId
        })
      }).then(({data}) => {
        if (data.msg==='success'){
          this.$message({
            message: '个人技能保存成功！',
            type: 'success',
            duration: '1200'
          });
        }else{
          this.$message.error('个人技能保存失败！');
        }
        this.dialogVisible = false;
        this.findData();
      })
    },
    findUserData(){//获取当前用户信息
     // this.user = JSON.parse(localStorage.getItem("user"))
       this.resume= JSON.parse(localStorage.getItem("resume"));
      this.form.resumeId = this.resume.id;
    },
    findPersonalSkillsData(){//获取用户的个人技能
      this.$http({
        url: this.$http.adornUrl(`/resume/skills/list/${this.resume.id}`),
        method: 'get'
      }).then(({data}) => {
        if(data.data!=='') {
          this.$emit('resumTest')
          this.skillsTableData = data.data
          this.form.skills = []
          for (let i=0;i<data.data.length;i++){
            this.form.skills.push(data.data[i].skills)
          }
        }
      })
    },
    async findData(){//获取数据
      this.findUserData();
      this.findPersonalSkillsData();
      //获取求职状态数据
      await this.$http({
        url: this.$http.adornUrl('/hope/skills'),
        method: 'get'
      }).then(({data}) => {
        this.skillsOptions = data
      })
    },
    addPersonalSkills(){//编辑
      this.dialogVisible = true
    }
  },
  created () {
    this.findData();
  }
}
</script>

<style scoped>

.warp__1CDpL .warp_r__1-t6m .icon_style__xOInT {
  width: 14px;
  height: 14px;
  margin-right: 5px;
  vertical-align: middle;
}

.warp__1CDpL .warp_r__1-t6m {
  margin-right: 50px;
  float: right;
  font-size: 14px;
  font-weight: 400;
  color: #02B28A;
  line-height: 28px;
  cursor: pointer;
}

.a1{
  border-left: 3px solid #00B38A;
  height: 16px;
  position: absolute;
  top: 24px;
  /*left: 30px;*/
}

.work__00001{
  font-size: 20px;
  font-weight: 600;
  color: #040404;
}

.warp_from__3BK0q {
  /*width: 780px;*/
  /*margin: 30px auto;*/
  padding: 30px 40px;
  /*padding-top: 0;*/
  background: #F8F9FB;
  border-radius: 2px;
  border: 1px dashed #E8E9EB;
}

.warp_from__3BK0q .title__12Fjr {
  margin: 30px 0;
  font-size: 16px;
  font-weight: 600;
  color: #00B38A;
}

.warp_from__3BK0q .input_warp__2AFbs {
  position: relative;
}

.warp_from__3BK0q .input_warp__2AFbs .fl_input_all__17UYa {
  margin-bottom: 20px;
}

.lg-form-item:first-child {
  margin-top: 0;
}

.lg-form-item {
  position: relative;
  margin-top: 22px;
}

.warp_from__3BK0q .input_warp__2AFbs .fl_input_all__17UYa div:first-child {
  width: 85px;
}

.lg-form-horizontal .lg-form-item-label {
  margin-bottom: 0;
  width: 90px;
}

.lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
  display: inline-block;
}

.lg-form-item-label {
  margin-bottom: 10px;
  font-size: 14px;
  color: #333;
  vertical-align: top;
}

.lg-form-horizontal .lg-form-item-label label {
  display: block;
  height: 40px;
  line-height: 40px;
  text-align: right;
}

.warp_from__3BK0q .input_warp__2AFbs .fl_input_all__17UYa div:last-child {
  width: 576px;
}

.lg-form-horizontal .lg-form-item-control {
  width: 300px;
  margin-left: 20px;
}

.lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
  display: inline-block;
}

.lg-form-item-control {
  position: relative;
}

.lg-input-affix-wrapper {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
  position: relative;
  display: inline-block;
  width: 100%;
  text-align: start;
}

.lg-form-item-control.feedback .lg-input {
  padding-right: 30px;
}

.lg-input-affix-wrapper .lg-input:not(:last-child) {
  padding-right: 30px;
}

.lg-input-affix-wrapper .lg-input {
  min-height: 100%;
}

.lg-input-affix-wrapper .lg-input {
  position: relative;
  text-align: inherit;
}

input[type=text], input[type=password], textarea {
  font-family: "Microsoft Yahei", "SimSun", Arial, "Helvetica Neue", Helvetica;
}

a, area, button, [role='button'], input:not([type='range']), label, select, summary, textarea {
  touch-action: manipulation;
}

input[type='text'], input[type='password'], input[type='number'], textarea {
  -webkit-appearance: none;
}

button, input, optgroup, select, textarea {
  margin: 0;
  padding: 0;
  border: 1px solid #ededed;
  border-radius: 0;
  font-family: "Hiragino Sans GB", "Microsoft Yahei", "SimSun", Arial, "Helvetica Neue", Helvetica;
}

.lg-input-affix-wrapper .lg-input-suffix {
  right: 12px;
}

.lg-input-affix-wrapper .lg-input-prefix, .lg-input-affix-wrapper .lg-input-suffix {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  color: #333;
  line-height: 0;
  transform: translateY(-50%);
}

[class^="icon-lg-"], [class*=" icon-lg-"] {
  font-family: "lagou-icon" !important;
  font-style: normal;
  font-weight: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.lg-input-affix-wrapper {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
  position: relative;
  display: inline-block;
  width: 100%;
  text-align: start;
}

.lg-input-affix-wrapper .lg-input-suffix {
  right: 12px;
}

.lg-input-affix-wrapper .lg-input-prefix, .lg-input-affix-wrapper .lg-input-suffix {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  color: #333;
  line-height: 0;
  transform: translateY(-50%);
}

[class^="icon-lg-"], [class*=" icon-lg-"] {
  font-family: "lagou-icon" !important;
  font-style: normal;
  font-weight: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.warp_from__3BK0q .input_warp__2AFbs {
  position: relative;
}

.lg-form-item:first-child {
  margin-top: 0;
}

.lg-form-item {
  position: relative;
  margin-top: 22px;
}

.warp_from__3BK0q .input_warp__2AFbs .fl_select__3zVXB > div:first-child {
  width: 85px;
}

.lg-form-horizontal .lg-form-item-label {
  margin-bottom: 0;
  width: 90px;
}

.lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
  display: inline-block;
}

.lg-form-item-label {
  margin-bottom: 10px;
  font-size: 14px;
  color: #333;
  vertical-align: top;
}

.lg-form-horizontal .lg-form-item-label label {
  display: block;
  height: 40px;
  line-height: 40px;
  text-align: right;
}

.warp_from__3BK0q .input_warp__2AFbs .fl_select__3zVXB > div:last-child {
  width: 580px;
}

.lg-form-horizontal .lg-form-item-control {
  width: 300px;
  margin-left: 20px;
}

.lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
  display: inline-block;
}

.lg-form-item-control {
  position: relative;
}

element.style {
  width: 49%;
  margin-right: 2%;
}

.lg-select-lg .lg-select-selection--single {
  height: 40px;
}

.lg-select-lg .lg-select-selection__rendered {
  line-height: 38px;
}

.lg-select-selection--single .lg-select-selection__rendered {
  margin-right: 24px;
}

element.style {
  display: block;
  opacity: 1;
}

.warp_from__3BK0q .input_warp__2AFbs .lg-select-selection-selected-value {
  font-size: 16px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

element.style {
  user-select: none;
}

.lg-select-arrow .lg-select-arrow-icon {
  transition: transform 0.3s;
}

[class^="icon-lg-"], [class*=" icon-lg-"] {
  font-family: "lagou-icon" !important;
  font-style: normal;
  font-weight: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
  box-sizing: border-box;
}

element.style {
  width: 49%;
}

.lg-select-lg .lg-select-selection--single {
  height: 40px;
}

.lg-select-lg .lg-select-selection__rendered {
  line-height: 38px;
}

.lg-select-selection--single .lg-select-selection__rendered {
  margin-right: 24px;
}

element.style {
  display: block;
  opacity: 1;
}

.warp_from__3BK0q .input_warp__2AFbs .lg-select-selection-selected-value {
  font-size: 16px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

element.style {
  user-select: none;
}

.lg-select-arrow .lg-select-arrow-icon {
  transition: transform 0.3s;
}

[class^="icon-lg-"], [class*=" icon-lg-"] {
  font-family: "lagou-icon" !important;
  font-style: normal;
  font-weight: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.button_w__9UtkX {
  margin-top: 20px;
  margin-left: 76px;
}

.myresume_container__3kIcL .fl_w__UKyBE .fl_l__297YX {
  float: left;
}

element.style {
  width: 88px;
}

.lgPrimaryButton__IV-Ot {
  background: #00b38a;
  border-radius: 2px;
  color: #ffffff;
}

.lgButton__1UxBx {
  width: 100px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  border-radius: 2px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  cursor: pointer;
  margin-right: 18px;
}

.myresume_container__3kIcL .fl_w__UKyBE .fl_l__297YX {
  float: left;
}

button, html [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
}

.lg-button {
  display: inline-block;
  margin: 0;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid #c4c4c4;
  text-shadow: none;
  box-shadow: none;
  cursor: pointer;
  outline: none;
  padding: 10px 15px;
  font-size: 12px;
  border-radius: 2px;
}

.work_btn_cancel__1XEeL {
  height: 40px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #666666;
  margin-left: 10px;
}

label, select, button, input[type="button"], input[type="reset"], input[type="submit"], input[type="radio"], input[type="checkbox"], input[type="file"] {
  cursor: pointer;
}

button, input, optgroup, select, textarea {
  margin: 0;
  padding: 0;
  border: 1px solid #ededed;
  border-radius: 0;
  font-family: "Hiragino Sans GB", "Microsoft Yahei", "SimSun", Arial, "Helvetica Neue", Helvetica;
}

button, select {
  text-transform: none;
}

button, input {
  overflow: visible;
}

input, button, select, optgroup, textarea {
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
}

.myresume_container__3kIcL .fl_w__UKyBE:after {
  content: '';
  height: 0;
  line-height: 0;
  display: block;
  visibility: hidden;
  clear: both;
}

*, *::before, *::after {
  box-sizing: border-box;
}

.lg-button-text {
  padding-left: 0;
  padding-right: 0;
  color: #00b38a;
  border-color: transparent;
  background-color: transparent;
}

.lg-modal-body {
  position: relative;
  font-size: 14px;
  color: #555;
}

.modal_title__1ED70 {
  margin-top: 30px;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  line-height: 20px;
}

.modal_flex__3fS28 {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.modal_list__3G7z1.active__3Bwk5 {
  background: rgba(0, 179, 138, 0.11);
  color: #00B38A;
}

.modal_list__3G7z1 {
  text-align: center;
  margin-top: 10px;
  width: 196px;
  height: 40px;
  background: rgba(244, 244, 246, 0.51);
  border-radius: 3px;
  font-weight: 400;
  color: #666;
  line-height: 40px;
  margin-right: 18px;
  cursor: pointer;
}

.modal_title__1ED70 {
  margin-top: 30px;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  line-height: 20px;
}

.modal_times_flex__1_Lej {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.modal_times_flex__1_Lej .modal_times_list__3kYL9 {
  width: 141px;
  text-align: center;
  margin-top: 10px;
  height: 40px;
  background: rgba(244, 244, 246, 0.51);
  border-radius: 3px;
  font-weight: 400;
  color: #666;
  line-height: 40px;
  margin-right: 18px;
  cursor: pointer;
}

.modal_times_flex__1_Lej .modal_times_list__3kYL9.active__3Bwk5 {
  background: rgba(0, 179, 138, 0.11);
  color: #00B38A;
}

.lg-modal-footer {
  position: relative;
  margin-top: 30px;
  text-align: left;
  box-sizing: border-box;
}

.lg-modal-OK {
  background-color: #00b38a;
  color: #fff;
  border-radius: 2px;
}

.lg-modal-OK, .lg-modal-cancel {
  display: inline-block;
  padding: 0 25px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
}

.lg-modal-cancel {
  padding: 0 25px;
  color: #666;
}

.lg-modal-OK, .lg-modal-cancel {
  display: inline-block;
  padding: 0 25px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
}


</style>
